<?php
class Solr_GlobalFunc{
    public static function get_solr_data ($solr_url) {
    	$curl = curl_init($solr_url);
    	curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type:text/xml; charset=utf-8"));
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($curl , CURLOPT_CONNECTTIMEOUT, 10);
    	curl_setopt($curl, CURLOPT_TIMEOUT, 5);
    	$res = curl_exec($curl);
    	$info = curl_getinfo($curl);
    	curl_close($curl);
    	if ($info['http_code'] != 200) {
    		return array();
    	}
		$resArray = simplexml_load_string($res);
    	//$resArray = json_decode($res,true);
    	return $resArray;
    }

    public static function create_solr_doc_number_url($host,$port,$appname){
    	$url="http://%s:%s%s/select/?q=*:*&start=0&rows=1";//&wt=json
    	return $url=sprintf($url,$host,$port,$appname);
    }
}